--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Node / ReticulumProjects / MeshChatX.git / files / docs / agents / skills / database-migrations-backups / SKILL.md
docs/agents/skills/database-migrations-backups/SKILL.md v4.8.1 (f6cc7b83) Text, 2.11 KB
Skill: database-migrations-backups
Bump schema versions correctly, keep backups and snapshots safe, and never conflate identity-key restore with full database zip restore.
When to use
• Changing SQLite schema or migrations
• Touching backup, snapshot, restore, or crash-recovery paths
• Adding tables / columns used by conversation or settings features
Schema rules
• Engine is SQLite with explicit SQL. No ORM.
• Bump T383838LATEST_VERSION in T383838meshchatx/src/backend/database/schema.py and add a migration path.
• Test upgrade from an older version when the change is non-trivial.
• Heavy data backfills in migrations should skip when the target table is empty. Fresh T383838Database Initialization benches create empty DBs and still run every migration step.
Backup and snapshot rules
• Backups skip T383838database-backups/ and T383838snapshots/ so a new zip does not nest itself (T383838BACKUP_SKIP_DIR_NAMES).
• Suspicious shrink writes T383838backup-SUSPICIOUS-*.zip and skips rotation. Do not treat that as a normal backup.
• Checkpoint WAL before zip snapshots when the live DB is open.
• Worker-thread connections must share T383838DatabaseProvider pragmas (see T383838landlock-sqlite).
Two restore operations
┌────────────────────────────────────┬─────────────────────────────────┬───────────────────────────┐
│ Goal │ API / CLI │ Artifact │
├────────────────────────────────────┼─────────────────────────────────┼───────────────────────────┤
│ Private key only │ T383838POST /api/v1/identity/restore │ identity key bytes / T383838.bin │
│ History + settings + identity tree │ T383838POST /api/v1/database/restore,… │ T383838.zip │
└────────────────────────────────────┴─────────────────────────────────┴───────────────────────────┘
Details for pickers and tutorial copy: T383838identity-restore.
Key files
• T383838meshchatx/src/backend/database/schema.py
• T383838meshchatx/src/backend/database/__init__.py
• T383838meshchatx/meshchat.py (backup / restore routes, T383838prepare_for_database_restore)
• T383838electron/offlineRecovery.js
Verification
T282828
uv run pytest tests/backend/test_database_snapshots.py tests/backend/test_schema_migration_upgrade.py -q --tbTff7b72=short
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────